package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import com.ysd.entity.NewsTable;
import com.ysd.entity.Productdetailsinfo;
import com.ysd.util.DBManager;

public class MohuDaoImpl {
		public ArrayList<Productdetailsinfo> getmohu(String name) {
			ArrayList<Productdetailsinfo> sou = new ArrayList<Productdetailsinfo>();
			Connection conn = DBManager.grtConnection();
			Statement st = null;
			ResultSet rs = null;
			try {
				st = conn.createStatement();
				String sql = "select * from Productdetailsinfo where productProductName like '%"+name+"%'";
				rs = st.executeQuery(sql);
				while(rs.next()) {
					String productProductName = rs.getString("productProductName");
					int cId = rs.getInt("cId");
					String img = rs.getString("img");
					Productdetailsinfo Productdetailsinfo = new Productdetailsinfo(productProductName, cId,img);
					sou.add(Productdetailsinfo);
				}
				return sou;
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return null;
			}finally {
				DBManager.closeAll(conn, st, rs);
			}

		}
}
